

//定义在ros中使用gstream的类

#ifndef __GSTCAMERA_H
#define __GSTCAMERA_H
extern "C" {
#include <gst/gst.h>
#include <gst/app/gstappsink.h>
}
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include "camera_info_manager/camera_info_manager.h"
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CameraInfo.h>
#include <sensor_msgs/SetCameraInfo.h>

#include <stdexcept>

namespace gstcamera
{
  class Gstcamera
  {
  public:
      Gstcamera(ros::NodeHandle nh_camera, ros::NodeHandle nh_private); //构造函数的形参是　两个句柄节点
      virtual ~Gstcamera();//析构函数

      //其他成员函数
  bool configure();
  bool init_stream();
  void publish_stream();
  void cleanup_stream();

  void run();


  
  private:
      //general gstreamer configuration
      std::string gstconfig_;

      //Gstreamer structures
      GstElement *pipeline_;
      GstElement *sink_;

      //Appsink configuration
      bool sync_sink_;
      bool preroll_;
      bool reopen_on_eof_;
      bool use_gst_timestamps_;

      // camera publisher configuration
      std::string frame_id_;
      int width_, height_;
      std::string image_encoding_;
      std::string camera_name_;
      std::string camera_info_url_;

      //calibration between ros::time and gst timestamps
      double time_offset_;

      //ros interface
      ros::NodeHandle nh_;
      ros::NodeHandle nh_private_;
      image_transport::ImageTransport image_transport_;
      camera_info_manager::CameraInfoManager camera_info_manager_;
      image_transport::CameraPublisher camera_pub_;

      //case of jpeg only publisher
      ros::Publisher jpeg_pub_;
      ros::Publisher cam_info_pub_;
      

  }; //class Gstcamera
  
} //namespace gstcamera







#endif  //ifend __gstcam_h
